// Problem: P1996 约瑟夫问题
// Contest: Luogu
// URL: https://www.luogu.com.cn/problem/P1996#submit
// Memory Limit: 125 MB
// Time Limit: 1000 ms
// 
// Powered by CP Editor (https://cpeditor.org)

#include<iostream>
#include<queue>

using namespace std;

int main()
{
    int n,m;cin>>n>>m;
    int i=0,cnt=0;
    queue<int> q;
    for(int i=1;i<=n;++i) q.push(i);
    while(!q.empty())
    {
    	++cnt,++i;
        if(cnt==m)
        {
        	cout<<q.front()<<" ";
            q.pop();
            cnt=0;
        }
        else
        {
            q.push(q.front());
            q.pop();
        }
    }
    return 0;
}